home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK2.toast / Development Kits (Disc 2) / QuickDraw GX / Programming Stuff / Sample Code / Printing Samples / Applications… / QuickDraw GX Aware Sample ƒ / Simple Sample ƒ / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-10  |  3.0 KB  |  135 lines  |  [TEXT/MMCC]

  1. /*********************************************************************
  2.  
  3.     main.c
  4.     
  5.     This file contains the main code and initialization routines for
  6.     the QuickDraw GX unaware sample, "Simple Sample."
  7.     
  8.     Additional info can be found in the related develop #19 article,
  9.     "Adding QuickDraw GX Printing to QuickDraw Applications."
  10.  
  11.     Dave Hersey, Apple Developer Technical Support.
  12.     
  13.     ——————— Edit Trail ———————
  14.     
  15.     creation:                                        1/22/94  - dmh
  16.     cleaned up for 2nd draft of develop article:    3/10/94  - dmh
  17.     cleaned up for final:                            4/14/94  - dmh
  18.     
  19. *********************************************************************/
  20.  
  21. #include "Simple Sample.h"
  22.  
  23. Rect                 gWindowRect = {50, 15, 512, 510};    // Our window size.
  24. short                 gAppResRefNum;                        // Our app's resource file refNum.
  25. long                gSleep = 0;                            // Sleep value for WaitNextEvent.
  26. Boolean                gQuitAfterPrinting = true;            // Quit after handling 'pdoc'?
  27. Boolean                gQuitting;                            // Quitting?
  28. Boolean                gSystemSevenIsPresent;                // System 7.0 or later is available?
  29.  
  30.  
  31. /************************************************************
  32.   MyInitialize - This routine performs the standard Mac
  33.   toolbox initialization.
  34.  
  35. *************************************************************/
  36.  
  37.  void MyInitialize()
  38.  {
  39.     CursHandle        theCurs; 
  40.     Handle            menuBar;
  41.  
  42. //    We're not quitting, and we don't have a print dialog displayed.
  43.  
  44.     gQuitting = false;
  45.  
  46. //    Initialize.
  47.  
  48.     InitGraf(&qd.thePort);
  49.     InitFonts();
  50.     InitWindows();
  51.     InitMenus();
  52.     InitCursor();
  53.  
  54. /*
  55.     See what system software is available.  If we don't have
  56.     what we need, bail.
  57. */
  58.     MyCheckConfig();
  59.     
  60.     if (!gSystemSevenIsPresent)
  61.     {
  62.         Alert(r_BadConfig, nil);
  63.         gQuitting = true;
  64.         return;
  65.     }
  66.  
  67. /*
  68.     Change to a watch cursor while we set up our menu bar
  69.     and then install our AppleEvent handlers.
  70. */
  71.     theCurs = GetCursor(watchCursor);
  72.     SetCursor(*theCurs);
  73.  
  74.     menuBar = GetNewMBar(rMenuBar);
  75.  
  76.     if (menuBar)
  77.     {
  78.         SetMenuBar(menuBar);
  79.         DisposHandle(menuBar);
  80.         AddResMenu(GetMHandle(mApple), 'DRVR');
  81.         DrawMenuBar();
  82.         SetCursor(&qd.arrow);
  83.  
  84.         MyDoAEInstallation();
  85.     }
  86. }
  87.  
  88.  
  89. /************************************************************
  90.   MyCheckConfig - This routine sets up our global
  91.   configuration variables based on results from Gestalt.
  92.  
  93. *************************************************************/
  94.  
  95. void MyCheckConfig()
  96. {
  97.     long    sysVersion;
  98.  
  99. //    Get the system version and see if it's 7.0 or later.
  100.  
  101.     gSystemSevenIsPresent = false;
  102.     
  103.     if (Gestalt(gestaltSystemVersion, &sysVersion) == noErr)
  104.         if (sysVersion >= 0x0700) gSystemSevenIsPresent = true;
  105. }
  106.  
  107.  
  108. /************************************************************
  109.   main - This is our main routine.  Not much else to say…
  110.  
  111. *************************************************************/
  112.  
  113. void main()
  114. {        
  115.     WindowPtr    wind;
  116.     char        i;
  117.  
  118.     gAppResRefNum = CurResFile();
  119.     MaxApplZone();
  120.     for (i = 1; i <= 6; i++)
  121.         MoreMasters(); 
  122.  
  123. //    Initialize the managers and jump into our event loop.
  124.  
  125.     MyInitialize();    
  126.  
  127.     while (!gQuitting)
  128.         MyEventLoop();
  129.  
  130. //    Leaving.  Close all the windows we opened.
  131.  
  132.     while (wind = FrontWindow())
  133.         MyDisposeDocument(MyGetDocPtr(wind));
  134. }
  135.